Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

249
Visualizações
Why is my document.querySelector() returning a [object HTMLDivElement] instead of the value?

I have the value 60% stored inside a <div class="value-container"> 60% </div>, however when use this query function document.querySelector(.value-container) to get the value, I get this response instead: [object HTMLDivElement]

Find below my HTML code:

<body>

    <div class="container">
        <div class="circular-progress">
            <div class="value-container"> 60% </div>
        </div>
    </div>

    <script>
        $(document).ready(function(){
            let testing = document.querySelector('.value-container');
            console.log("Testing: " +testing);
        });            
    </script>

</body>

This code above yields:

Testing: [object HTMLDivElement]

The desired yield is:

Testing: 60%

How do I capture the value stored inside my <div class="value-container"> 60% </div>?

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

As mentioned above, query selector returns an element, but to get its inner value document.querySelector('.value-container').innerHTML should be added

about 4 years ago · Juan Pablo Isaza Relatório

0

The other commenters are correct - you need do something with the object you get back from your querySelector.

But if you only care about the raw text (which it looks like in this case as you just want the 60% value), then document.querySelector('.value-container').textContent is slightly more efficient than innerHTML

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda